cmake_minimum_required(VERSION 3.20)
set(CMAKE_CXX_STANDARD 14)

# 项目名称
project(ElementCalculator LANGUAGES CXX)

# 获取源文件
set(SOURCES
    Factory/ElementCalculatorFactory.cpp
    Register/ElementCalculatorRegister.cpp

    SolidElement/SolidMaterialParser.cpp
    SolidElement/Tetra4ElementCalculator.cpp
    SolidElement/Hexa8SRIElementCalculator.cpp
    ScalarElements/ELAS1Calculator.cpp
    ScalarElements/MASSiCalculator.cpp
    MassElement/Conm1ElementCalculator.cpp
    MassElement/Conm2ElementCalculator.cpp
    RodElement/RodCalculator.cpp
    BarElement/BarCalculator.cpp
    BarElement/BarSectionParser.cpp
    ShearElement/ShearElementCalculator.cpp
    BushElement/BushCalculator.cpp
    ThermalElement/Hexa8ThermalCalculator.cpp
    ThermalElement/Quad4ThermalCalculator.cpp
    ThermalElement/Tetra4ThermalCalculator.cpp
    ThermalElement/Tria3ThermalCalculator.cpp
    ThermalElement/CHBDYGAREACalculator.cpp
    ThermalElement/CHBDYPLINECalculator.cpp
    )

# 添加动态库
add_library(${PROJECT_NAME} SHARED ${SOURCES})

# 目标添加链接库
target_link_libraries(${PROJECT_NAME}
    PRIVATE BeamSecPropCalculator Integration Framework DBManager DataStructure Algebra Configuration Logging)
# 目标添加编译选项
target_compile_definitions(${PROJECT_NAME} PRIVATE EXPORTING_ElementCalculator)

# 安装头文件
install(DIRECTORY ${PROJECT_SOURCE_DIR}/Common/    DESTINATION include/SGFem/ElementCalculator/Common)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/Interface/ DESTINATION include/SGFem/ElementCalculator/Interface)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/Factory/   DESTINATION include/SGFem/ElementCalculator/Factory  FILES_MATCHING PATTERN "*.h" PATTERN "UnitTest" EXCLUDE)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/Register/  DESTINATION include/SGFem/ElementCalculator/Register FILES_MATCHING PATTERN "*.h")
install(FILES ${PROJECT_SOURCE_DIR}/SolidElement/SolidMaterialParser.h DESTINATION include/SGFem/ElementCalculator/SolidElement)

# 安装目标
install(TARGETS ${PROJECT_NAME}
    ARCHIVE DESTINATION lib
    RUNTIME DESTINATION bin)

# 添加单元测试子项目
if(SG_BUILD_UNIT_TEST)
    add_subdirectory(UnitTest)
endif()